package com.wkhyapp.lm.weigit.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.RelativeLayout;

import com.wkhyapp.lm.R;
import com.wkhyapp.lm.adapter.CategoryAdapter;
import com.wkhyapp.lm.http.vo.Category;

import java.util.List;

/**
 * Created by fang on 2021/10/15.
 */

public class ContactAppDialog {
    private Dialog mDialog;
    private Context mContext;
    private View dialog_view;
    public ContactAppDialog.callBack mCallBack;
    RelativeLayout save_rl;
    RelativeLayout copy_rl;
    private String url,wx,qq;
    public ContactAppDialog(Context context, String url, String wx, String qq) {
        this.mContext = context;
        this.url = url;
        this.wx = wx;
        this.qq = qq;
        init();
    }

    public void init() {
        mDialog = new Dialog(mContext, R.style.custom_dialog);
        dialog_view = LayoutInflater.from(mContext).inflate(R.layout.dialog_contact, null);
        save_rl = (RelativeLayout) dialog_view.findViewById(R.id.save_rl);
        copy_rl = (RelativeLayout) dialog_view.findViewById(R.id.copy_rl);
        mDialog.setContentView(dialog_view);

        Window window = mDialog.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.CENTER; // 居中位置
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);

        save_rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.downLoad(url);
            }
        });


        copy_rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.copy(wx);
            }
        });
    }

    public void close() {
        mDialog.dismiss();
    }

    public void show() {
        mDialog.show();
    }

    public void setCallBack(ContactAppDialog.callBack callBack) {
        this.mCallBack = callBack;
    }


    public interface callBack {
        void downLoad(String url);
        void copy(String str);
    }
}